<template>
	<view class="cu-load load-modal" v-if="loadModal">
		<image src="/static/opts/logo-s.png" mode="aspectFit"></image>
		<view class="gray-text">加载中...</view>
	</view>
</template>

<script>
	import {
		login_wxoa
	} from '@/common/api/auth.js'

	export default {
		data() {
			return {
				loadModal: false
			}
		},
		onLoad(e) {
			this.loadModal = true
			console.log("onLoad", e)
			uni.removeStorageSync("userInfo")
			uni.removeStorageSync("cardInfo")
			if (e.code) {
				login_wxoa({
					code: e.code
				}).then(res => {
					this.loadModal = false
					let data = this.$s.res(res)
					uni.setStorageSync("userInfo", data)
					uni.setStorageSync('jwt-token', data['jwt-token'])
					if (data.phone) {
						uni.reLaunch({
							url: '/pages/index'
						})
					} else {
						uni.reLaunch({
							url: '/pagesB/phone'
						})
					}
				})
			}

		}
	}
</script>

<style>
</style>